package cn.jingyuan.swan.system.web.restful;

import cn.jingyuan.swan.cloud.core.RestResult;
import cn.jingyuan.swan.system.model.dto.GatewayRouteDto;
import cn.jingyuan.swan.system.web.restful.model.GatewayRouteAddRequest;
import cn.jingyuan.swan.system.web.restful.model.GatewayRouteUpdateRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

/**
 * 网关路由服务
 */
public interface GatewayRouteRestful {

    /**
     * 添加路由
     *
     * @return 路由 id
     */
    @GetMapping(path = "/route/add", produces = APPLICATION_JSON_VALUE)
    RestResult<Long> addRoute(@RequestBody GatewayRouteAddRequest reqDto);

    /**
     * 移除路由
     */
    @PostMapping(path = "/route/remove", produces = APPLICATION_JSON_VALUE)
    RestResult<Void> removeRoute(@RequestBody List<Long> ids);

    /**
     * 更新路由
     */
    @PostMapping(path = "/route/update", produces = APPLICATION_JSON_VALUE)
    RestResult<Void> updateRoute(GatewayRouteUpdateRequest reqDto);

    /**
     * 获取路由列表
     *
     * @return 路由列表
     */
    @GetMapping(path = "/route/routes", produces = APPLICATION_JSON_VALUE)
    RestResult<List<GatewayRouteDto>> getRoutes();

}
